package ift585.test;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;

public class Client {

	static final int SENDING_PORT = 65500;
	static final int tailleBuffer = 1024;
	static final byte buffer[] = new byte[tailleBuffer];
	
	private DatagramSocket client = null;
	
	public Client() throws IOException{
		client = new DatagramSocket();
	}
	
	public void execute() throws IOException{
		InetAddress adresseServeur = InetAddress.getLocalHost();
		
		String message = "salut";
		byte buffer[] = message.getBytes();

		DatagramPacket paquetEnvoie = new DatagramPacket(buffer, message.length(), adresseServeur, SENDING_PORT);
		
		client.send(paquetEnvoie);
	}
	
	public static void main(String[] args) {
		
		try {
			Client unClient = new Client();
			for (int i = 0; i < 50; i++) {
				unClient.execute();
			}
		} catch (Exception e) {
			System.out.println(e.getMessage());
		}
	}
}
